package me.aartikov.simplenavigationsample;

import me.aartikov.alligator.*;
import me.aartikov.alligator.navigationfactories.GeneratedNavigationFactory;
import me.aartikov.alligator.navigationfactories.NavigationFactory;
import ohos.aafwk.ability.AbilityPackage;
import ohos.app.ElementsCallback;
import ohos.global.configuration.Configuration;

public class SampleApplication extends AbilityPackage {
    private static OhosNavigator sOhosNavigator;

    public static void setsOhosNavigator(OhosNavigator sOhosNavigator) {
        SampleApplication.sOhosNavigator = sOhosNavigator;
    }

    @Override
    public void onInitialize() {
        super.onInitialize();
        setsOhosNavigator(new OhosNavigator(new GeneratedNavigationFactory())); // It is ok if GeneratedNavigationFactory is not defined. Just build the project to generate it.
        registerCallbacks(AbilityStack.getInstance(), new ElementsCallback() {
            @Override
            public void onMemoryLevel(int i) {

            }

            @Override
            public void onConfigurationUpdated(Configuration configuration) {

            }
        });
    }

    // In a real application use dependency injection framework to provide these objects.

    public static Navigator getNavigator() {
        return sOhosNavigator;
    }

    public static NavigationFactory getNavigationFactory() {
        return sOhosNavigator.getNavigationFactory();
    }

    public static NavigationContextBinder getNavigationContextBinder() {
        return sOhosNavigator;
    }

    public static ScreenResolver getScreenResolver() {
        return sOhosNavigator.getScreenResolver();
    }
}
